//package com.chuang.server.config.security;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.concurrent.Semaphore;
//import java.util.concurrent.TimeUnit;
//
///**
// * @program: cheyoufu-report
// * @description: TODO
// * @author: dp
// * @create: 2020-01-13 13:22
// **/
//@Slf4j
//@Configuration
//public class QueueUpInterceptor implements HandlerInterceptor {
//    private Semaphore semaphore = new Semaphore(100);
//    @Override
//    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
//        httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
//        httpServletResponse.setHeader("Access-Control-Allow-Methods", "*");
//        httpServletResponse.setHeader("Access-Control-Allow-Headers", "*");
//        httpServletResponse.setHeader("Access-Control-Max-Age","1800");
//
//        try {
//            log.info("semaphore.availablePermits :{}", semaphore.availablePermits());
//            semaphore.tryAcquire(1, 10, TimeUnit.SECONDS);
//            return true;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return false;
//        }
//    }
//    //记录操作日志,只拦截增加、删除、修改保存接口,查询接口放行
//    //编辑保存接口修改前后信息
//    @Override
//    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
//
//
//    }
//
//    @Override
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//        log.info("afterCompletion availablePermits :{}", semaphore.availablePermits());
//        semaphore.release();
//        log.info("release-->semaphore.availablePermits :{}", semaphore.availablePermits());
//    }
//
//
//}
